package com.example.myapplication.intent;

import androidx.appcompat.app.AppCompatActivity;

import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import com.example.myapplication.R;

public class FirstActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_first);
    }

    public void senMessage(View view) {
        EditText meg = findViewById(R.id.message);
        String s = meg.getText().toString();
        ///--------显式启动------
        ///class跳转
        /*Intent intent = new Intent(this,SecondActivity.class);
        startActivity(intent);*/
        ///包名，类名跳转
        /*Intent intent = new Intent();
        intent.setClassName(this,"com.example.myapplication.intent.SecondActivity");
        startActivity(intent);*/
        ///ComponentName跳转
        /*Intent intent = new Intent();
        ComponentName cname = new ComponentName(this,SecondActivity.class);
        intent.setComponent(cname);
        startActivity(intent);*/
        ///--------隐式启动--------
        /*Intent intent = new Intent();
        intent.setAction("action.nextActivity");*/
        Intent intent = new Intent("action.nextActivity");
        startActivity(intent);
    }
}